# -*- coding:utf-8 -*-
# author: helili
# @Time: 2020/11/25 上午9:47


import unittest
import os
import sys

from BeautifulReport import BeautifulReport

from UICaseRunner.config import project_config
from UITestProj.settings import BASE_DIR

current_directory = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(os.path.dirname(current_directory) + os.path.sep + ".")
sys.path.append(root_path)


def beautiful_report_run():

    # BeautifulReport生成html测试报告
    suite = unittest.defaultTestLoader.discover(BASE_DIR + '/UICaseRunner/', 'test_case.py')
    result = BeautifulReport(suite)
    result.report(
        filename='beautiful_filename',
        # 测试报告文件名称, 如果不指定，默认文件名为report.html
        description='beautiful_description',
        # 测试报告名称展示
        report_dir=BASE_DIR+'/UICaseRunner',
        # 测试报告文件写入路径
        theme="theme_default",
        # 测试报告主题样式
    )

    # 日志
    logger = project_config.logger
    logger.info("用例总数：{}", result.testsRun)
    logger.info("通过总数：{}", result.success_count)
    logger.info("失败总数：{}", result.failure_count)
    logger.info("跳过总数：{}", result.skipped)
    logger.info("错误总数：{}", result.error_count)



